/*
 * CXMLParser.cpp
 *
 *  Created on: 4 oct. 2009
 *      Author: Maxime Gaudin
 */

#include "CXMLParser.h"

CXMLParser::CXMLParser()	: itemRegex			("<item>([.]*)</item>")
							, titleRegex		("<title>([.]*)</title>")
							, linkRegex			("<link>([.]*)</link>")
							, categoryRegex		("<category>([.]*)</category>")
							, descriptionRegex	("<description>([.]*)</description>")
							, pubDateRegex		("<pubDate>([.]*)</pubDate>")
{

}

CXMLParser::~CXMLParser() {

}

std::vector<std::string> CXMLParser::getItems(std::string xmlSource)
{
	std::vector<std::string> items;
	boost::cmatch matches;

	boost::regex_match(xmlSource.c_str(), matches, itemRegex);

	for(unsigned int i = 1; i < matches.size(); i++)
		items.push_back(std::string(matches[i].first, matches[i].second));

	return items;
}
